#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char **argv) {
  string infile = "chapter8/1.txt";
  vector<string> vec;
  ifstream in(infile);
  if (in) {
    string buf;
    while (getline(in, buf)) {
      vec.push_back(buf);
    }
  } else {
    cerr << "cannot open this file: " << infile << endl;
  }
  for (int i = 0; i < vec.size(); ++i) {
    istringstream iss(vec[i]); //将istringstream与vec[i]相绑定
    string word;
    while (iss >> word)
      cout << word << endl;
  }

  return 0;
}
